package com.siblings.loan.ui.loan.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.lib.base.utils.ImageUtil
import com.siblings.lib_baseadapter.SIBRecyclerViewAdapter
import com.siblings.lib_baseadapter.SIBViewHolderHelper
import com.siblings.loan.R
import com.siblings.loan.config.SibConfigs
import org.json.JSONObject

/**
 * Siblings
 * @Author wwdeng
 * @CreateTime: 2024/4/19 12:02
 * @Annotation：贷款已绑定账户适配器
 */
class SibLoanAccountAdapter(recyclerView: RecyclerView?): SIBRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.item_loan_account) {

    override fun setItemChildListener(helper: SIBViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.deleteLayout)//删除
    }

    override fun fillData(helper: SIBViewHolderHelper, position: Int, model: JSONObject) {
        helper.setText(R.id.textName,model.optString("name"))
        helper.setText(R.id.textNumber,"+" + model.optString("account"))

        val imgLogo = helper.getImageView(R.id.imgLogo)
        ImageUtil.instance!!.loadImageUrl(mContext,imgLogo,model.optString("logo"), com.lib.base.R.mipmap.icon_holder)

        //只有法语地区才显示删除账号按钮
        if (SibConfigs.isFrench()){
            helper.setVisibility(R.id.deleteLayout, View.VISIBLE)
        } else {
            helper.setVisibility(R.id.deleteLayout, View.GONE)
        }
    }
}